<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../public/css/monokai_sublime.min.css">
    <link rel="stylesheet" href="../../public/css/heightlength.css">
    <link rel="stylesheet" href="../../public/css/mxjs.css">
    <link rel="stylesheet" href="../../public/css/prism.css">
    <script src="../../public/js/jquery.js"></script>
    <script src="../../public/js/highlight.min.js"></script>
    <script src="../../public/js/prism.js"></script>
    <script src="../../public/js/clipboard.min.js"></script>

</head>
<body>
<button>点击</button>
<div class="container">
    <div class="jsbg">
        <div class="col-lg-12 mxlength">
            <div class="mx-1">
                <h2>bind,call,apply使用方式和原理</h2>

                    类或者方法调用.call
                    .bind
                    .apply
                    第一个参数必须是个对象
                    调用kli方法，让kli方法里面的this指向第一个对象;
                    <div>
                        let arr = [1, 22, 3, 44, 5, 66, 7, 88, 9];
                        let max = Math.max.apply(Math, arr);
                        console.log(max);
                    </div>

            </div>
        </div>
        <div class="col-lg-12  ">
      <pre class="mScroll">
        <code class="lang-javascript">
  function kli(a,b){
       console.log(this.name)
   }
   let obj={name:33}
   kli.call(obj,1,3)
   kli.apply(obj,[1,3])
   kli.bind(obj,1,3)()
		</code>
    </pre>
        </div>
    </div>
</div>
<script>

    window.onload = function () {
        var clipboard = new Clipboard('.toolbar-item');
        clipboard.on('success', function (e) {
            console.log(e.text);
        });
        clipboard.on('error', function (e) {
            console.log(e);
        });
        $(".toolbar-item").html("<span>复制</span>")
    }
</script>
</body>
</html>
